package moodish.tests;

import moodish.comm.ServerSideMessage.Type;
import moodish.server.Server;

public class ServerTests {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		Server servidor = new Server();

		try {

			// Cria uns quantos clientes

			servidor.connectNewUser("Joao");
			servidor.connectNewUser("Paulo");
			servidor.connectNewUser("Tiago");
			servidor.connectNewUser("Catarina");

			ServerMessage friend1 = new ServerMessage(Type.FRIENDSHIP, "Tiago",
					"Joao");
			ServerMessage friend2 = new ServerMessage(Type.FRIENDSHIP, "Paulo",
					"Joao");
			ServerMessage friend3 = new ServerMessage(Type.FRIENDSHIP, "Paulo",
					"Catarina");

			servidor.handleFriendshipMessage(friend1);
			servidor.handleFriendshipMessage(friend2);
			servidor.handleFriendshipMessage(friend3);

			servidor.connectUser("Antonio");

			ServerMessage mood1 = new ServerMessage(Type.MOODISH_MESSAGE,
					"ESTOU FARTO DE ES", "Paulo");

			servidor.handleMoodishMessage(mood1);

			servidor.disconnectUser("Paulo");

		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	public static void nameListOutput(String[] nameList) {

		String output = "\nName List\n";

		for (int i = 0; i < nameList.length; i++) {

			output = output + (i + 1) + ": ";

			output = output + nameList[i];
			output = output + "\n";
		}

		output = output + "<End of User List>\n";

		System.out.println(output);
	}
}
